
local mt = ac.skill['召唤单位']
mt.art = [[ReplaceableTextures\CommandButtons\BTNBlizzard.blp]]
mt.temp = '自动释放'
mt.cooling_flag = true
mt.summon_count = 1
mt.summon_time = 30
mt.summon_unit = 'hfoo'

function mt:on_run(hero)
    local angle = hero:get_facing()
    local point = hero:get_point() - {angle,150}
    local temp = self:create_cast()
    if hero:dispatch('单位-拦截召唤',hero,temp) then
        return
    end
    if temp.summon_group then
        local group = hero:get_data(temp.summon_group) or {}
        for _,unit in ipairs(group) do
            unit:kill()
        end
    end
    local group = {}
    for a=1,temp.summon_count do
        local enter = point:find_summon_point(512,angle) or point
        local unit = hero:create_unit(temp.summon_unit,enter,angle)
        unit_add_life2(unit)
        temp:notify('set_summon',unit)
        unit:add_buff('召唤物'){time = temp.summon_time}
        table.insert(group,unit)
    end
    if temp.summon_group then
        hero:set_data(temp.summon_group,group)
    end
end
